<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>清单应用Vue版</title>
  <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/3.2.31/vue.global.min.js"></script>
</head>

<body>

  <div id="app">
    <h2>{{title}}</h2>
    <input type="text" v-model="newItem">
    <button @click="addItem">添加</button>
    <ul>
      <li v-for="(item, index) in items" :key="index">{{ item }}</li>
    </ul>
  </div>
  <script>
    const app = Vue.createApp({
      data() {
        return {
          title: '清单应用Vue版',
          newItem: '',
          items: []
        }
      },
      methods: {
        addItem() {
          if (this.title.trim() !== '') {
            this.items.push(this.newItem)
            this.newItem = ''
          }
        }
      }
    }).mount('#app')
  </script>
</body>

</html>